package com.loveprogrammer.eternity.skill.support.states;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.console.ConsolePrint;

import java.util.List;

/**
 * @version 1.0.0
 * @description: 灼烧状态
 * @author: eric
 * @date: 2022-12-16 16:45
 **/
public class BurnState extends AbstractNegativeState{

    private int reduceHp;

    public BurnState(Character character, List<? extends Character> camp, int reduceHp) {
        super(character,camp);
        this.reduceHp = reduceHp;
    }

    @Override
    public int id() {
        return 22;
    }

    @Override
    public String name() {
        return "灼烧";
    }

    @Override
    public String desc() {
        return "灼烧，每秒钟减血";
    }

    @Override
    public void doReset() {

    }

    @Override
    public int counterId() {
        return 91;
    }

    @Override
    public void run() {
        // 如果已经死了就算了
        if(this.getCharacter().checkDead()){
            return;
        }
        // 否则
        // 查看对方的火抗
        int reduceReal = (int) (reduceHp * (1 - getCharacter().getFlameResistance() * 1.0 / 100));
        getCharacter().hp().addAndGet(-reduceReal);
        ConsolePrint.publishMessage(string + getCharacter().getName() + "(" + getCharacter().getCurrentHp() + "/" +
                getCharacter().getHpMax() + ")" + "灼烧失去生命值" + reduceReal);
        if (getCharacter().checkDead()) {
            getNotify().publishDeadEvent(getCharacter(),getCamp());
        }
    }
}
